package com.heima.search.controller;

import com.heima.common.PageResult;
import com.heima.common.Result;
import com.heima.dto.SearchDTO;
import com.heima.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    SearchService searchService;

    /**
     * 功能描述:  1、创建索引库和映射
     * @return : com.heima.common.Result
     */
    @GetMapping("createIndex")
    public Result createIndexAndMapping() throws IOException {
        Result result = searchService.createIndexAndMapping();
        return result;
    }
    /**
     * 功能描述: 2、全量索引库
     * @return : com.heima.common.Result
     */
    @GetMapping("/importData")
    public Result importData(){
        searchService.importData();
        return new Result(200,"DB同步数据到ES成功！",true);
    }
    /**
     * 增量索引
     */

    /**
     *  关键字搜素-搜素面板过滤条件、高亮、排序、分页、函数分值
     */
    public PageResult search(SearchDTO searchDTO){
        PageResult result = searchService.search(searchDTO);
        return result;
    }


    /**
     *  自动补全
     */

    /**
     *  查询搜素记录
     */

    /**
     *  搜索热词
     */
}
